﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HMIS.FrameWork.DomainBase;
using HMIS.FrameWork;
using Iesi.Collections.Generic;

namespace HMIS.Infrastructure.Core.Authority
{
	/// <summary>
	/// 角色
	/// </summary>
	public class Role : BaseEntity
	{
		private string name;
		private string code;

		/// <summary>
		/// 角色名称
		/// </summary>
		public virtual string Name
		{
			get
			{
				return this.name;
			}
			set
			{
				if (String.IsNullOrEmpty(value))
					throw new NotNullException();
				this.name = value;
			}
		}
		/// <summary>
		/// 代码
		/// </summary>
		public virtual string Code
		{
			get
			{
				return this.code;
			}
			set
			{
				if (String.IsNullOrEmpty(value))
					throw new NotNullException();
				this.code = value;
			}
		}

		/// <summary>
		/// 角色状态
		/// </summary>
		public virtual RoleState State { get; set; }

		/// <summary>
		/// 角色下的用户
		/// </summary>
		[System.Xml.Serialization.XmlIgnore]
		public virtual Iesi.Collections.Generic.ISet<Person> Persons { get; set; }

		/// <summary>
		/// 角色拥有的菜单权限
		/// </summary>
		[System.Xml.Serialization.XmlIgnore]
		public virtual Iesi.Collections.Generic.ISet<MenuNode> MenuNodes { get; set; }

		/// <summary>
		/// 角色拥有的功能权限
		/// </summary>
		[System.Xml.Serialization.XmlIgnore]
		public virtual Iesi.Collections.Generic.ISet<ActionPermission> ActionPermissions { get; set; }
	}

	/// <summary>
	/// 角色状态
	/// </summary>
	public enum RoleState
	{
		[EnumDescription("正常")]
		Normal = 0,

		[EnumDescription("停用")]
		Disabled = 1
	}
}
